<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>家访照片列表</title>
<jsp:include page="../../import.jsp" flush="true" />
<script type="text/javascript">
var prjId='${prjId}'
var detailFlag='${detailFlag}'
	var grid = null;
	$(function () {
		var _tabNm = "PRJ_BSC_INFO";
		var data = {};
		var _url = '<%=path%>/project/prjbscinfo/initVisitList.do?prjId='+prjId;
	    $("#ligergrid1").ligerGrid({
	    	url: _url,
	    	method : 'get',
	    	dataType:'json',
	        columns: [
				{ display: '描述', name: 'datNm', minWidth: 100},
			   { display: '文件名', name: 'fileRec.fileNm', minWidth: 100,
				   	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            		if(rowdata.fileRec){
		            		if(rowdata.fileRec.filePath){
		            			if(SQ.regs.img.test(rowdata.fileRec.filePath)){
		            				  h+='<a  target="_blank" onclick="showImg(event);" href="'+rowdata.fileRec.filePath;
				                        h+='">'+value+'</a>'
		            			}else{
		            				  h+=value;
		            			}
	                        
		            		}
	            		}
	                        return h;
	            		}
				},
		       { 
	            	display: '下载', 
	            	name: 'filePath', 
	            	minWidth: 100,
	            	render: function (rowdata, rowindex, value){
	            		var h = "";
	            		if(rowdata.fileRec){
		            		if(rowdata.fileRec.filePath){
		            			var _url = '<%=path%>/project/prjbscinfo/downLoad.do?fileId='+rowdata.fileRec.id;
			                      h+='<a target="_blank"  href="'+_url+'">'+ '下载附件' +'</a>';
		            		}
	            		}
	                    return h;
	                }	
	            },
	            {	display: '操作',
			        isSort: false,
			        width: 200,
			        render: function (rowdata, rowindex, value){
			        	var h="";
			        	if(detailFlag!="true"){
			        		  var h='<a class="sq-button-hasicon" href="javascript:uploadFile(';
				                h+="'"+rowdata.sysCd+"',";
				                h+="'"+rowdata.orgCd+"',";
				                h+="'"+rowdata.cfgCd+"',";
				                h+="'"+rowdata.cfgDtlCd+"',";
				                h+="'"+rowdata.cfgDtId+"'";
				                h+=')"><i class="sqBtnIco_9"></i>上传</a>';
				                if(rowdata.fileRec){
				                if(rowdata.fileRec.id){
				          	   h+='<a class="sq-button-hasicon" href="javascript:removeFileRec(';
				                h+="'"+rowdata.fileRec.id+"'";
				                h+=')"><i class="sqBtnIco_7"></i>删除</a>';
				                }
				                }
			        		}
			     /*            h+='<a class="sq-button-hasicon" href="javascript:showPhoto(';
			                h+="'"+rowdata.id+"'";
			                h+=')"><i class="sqBtnIco_2"></i>查看</a>'; */
			            return h;
			        }
				}
	        ],
	        
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        heightDiff:-2,
	        checkbox:false,
	        allowUnSelectRow: true,
            alternatingRow: false,
	        rownumbers:true,
	        usePagerOnLessPagesize: false,
	        onAfterShowData: function () {
	            $( ".gridTip").grid_ligerTip();
	            SetIframe_height ();
	       }
	    });
	    grid = liger.get("ligergrid1");
	    if(detailFlag=="true"){
	    	$("#addBtn").hide();
	    }
	});
	
	function showImg(e){
		 e.preventDefault();
        var href = $(e.target).attr('href');
            SQ.imgPreview(href);
	}
	function removeFileRec(id){
		if(!id){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW , SQ_type: "warning" });
			return;
		}
		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:id},
				url: '<%=path%>/system/sysulfilesrec/removeById.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
	
	function uploadFile(sysCd,orgCd,cfgCd,cfgDtlCd,cfgDtId){
        $.ligerDialog.open({ height: 300,width: 500, url: '<%=path%>/project/prjbscinfo/addInvestImgPage.do?sysCd='+sysCd+'&&orgCd='+orgCd+'&&cfgCd='+cfgCd+'&&cfgDtlCd='+cfgDtlCd+'&&cfgDtId='+cfgDtId+'&&prjId='+prjId, isResize: true});
	}
	
	function checkImg(path){
		var flag = true;
	       reg = new RegExp('^.*\.(?:png|jpg|bmp|gif|jpeg|PNG|JPG|BMP|GIF|JPEG)$');
	        if (!reg.test(path)) {
	        	flag = false;
	        };
	        return flag;
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
    <%--  $.ligerDialog.open({ height: 500,width: 600, url: '<%=path%>/project/prjbscinfo/toPhotosDetailPage.do?id='+id, isResize: true});  --%>

</script>
</head>
<body class="iframeBody">
<div class="Wrapper">
	  <div class="pageIn2layout">
	<jsp:include page="../../project/prjbscinfo/prjInvestRpt.jsp" flush="true" >
			<jsp:param name="currentNav" value="prjVisitPhotos"/>
	</jsp:include>
	<div class="pageIn2L_mid">
        <div class="fieldset1 tabel_col tabel_col_s clearFix">
	                            <div class="caption">
	                                <span class="title">家访照片信息 </span>
	                            </div>
	                 <div class="clearFix"></div>
					<!--  <div class="btnsBox">
		               <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round"><i class="sqBtnIco_3"></i>新增</span>
		            </div> -->
		            <div id="ligergrid1" class="sq-grid"></div>
			</div>
	</div>
</div>
</div>
</body>
</html>